/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package classcreator;

import java.util.Vector;

/**
 *
 * @author Stefano
 */
public class StateMachineRepository extends Vector<StateMachine>{
    public TypeRepository typeRepository;
    
    public StateMachineRepository(TypeRepository typeRepository){
        this.typeRepository=typeRepository;
    }
    
    public boolean add(StateMachine dt){
        for(StateMachine dtt:this){
            if(dt.name.equals(dtt.name)) return false;
        }
        if(typeRepository.contains(dt.getType())) return false;
        boolean res=super.add(dt);
        if(res) typeRepository.add(dt.getType());
        return res;
    }
   
    public boolean remove(StateMachine dt){
        boolean res=super.remove(dt);
        if(res) typeRepository.remove(dt.getType());
        return res;
    }
}
